/**
 * 
 */
package com.shy.config;

import java.util.concurrent.TimeUnit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * <p>Title:WebMvcConfig
 * <p>Description:
 * @author shanhanyu
 * @date 2019年8月16日
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

	@Autowired
    private FileUploadProperteis fileUploadProperteis;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler(fileUploadProperteis.getStaticAccessPath())
				.addResourceLocations("file:" + fileUploadProperteis.getUploadFolder() + "/")
				.setCacheControl(CacheControl.maxAge(3600, TimeUnit.SECONDS));
		registry.addResourceHandler(fileUploadProperteis.getTemplateStaticPath())
				.addResourceLocations("file:" + fileUploadProperteis.getTemplateFolder() + "/")
				.setCacheControl(CacheControl.maxAge(3600, TimeUnit.SECONDS));
    }
}
